home *** CD-ROM | disk | FTP | other *** search
- // ===============================================================
- // Vertex Program:
- // Description:
- // Last Update: 14/08/2003
- // Coder: Andrey Honich
- // ===============================================================
-
- #include "../CGVPMacro.csi"
-
-
- VertAttributes { POSITION_3 TEXCOORD0_2 TANG_3X3 }
- MainInput { VIEWPROJ_MATRIX, LIGHT_POS, CAMERA_POS, ATTEN }
- DeclarationsScript
- {
- IN_T0_TANG
- OUT_T0_T1_C0_C1
- }
- PositionScript = PosCommon
- CoreScript
- {
- OUT.Tex0.xy = IN.TexCoord0.xy;
- OUT.Tex1.xy = IN.TexCoord0.xy;
-
- TANG_MATR
-
- // store normalized light vector
- float3 lightVec = LightPos.xyz - vPos.xyz;
- float fiSqDist = rsqrt(dot(lightVec,lightVec));
- lightVec = lightVec * fiSqDist;
- OUT.Color.w = PROC_ATTENVERT;
-
- // transform light vector from object space to tangent space and pass it as a color
- OUT.Color.xyz = 0.5 * mul(objToTangentSpace, lightVec.xyz) + 0.5.xxx;
-
- // compute view vector
- float3 viewVec = normalize(CameraPos.xyz - vPos.xyz);
-
- // compute half angle vector
- float3 halfAngleVector = normalize(lightVec.xyz + viewVec);
-
- // transform half angle vector from object space to tangent space and pass it as a color
- OUT.Color1.xyz = 0.5 * mul(objToTangentSpace, halfAngleVector) + 0.5.xxx;
- }
-